package com.hnhcyy.goods.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import com.hnhcyy.goods.pojo.GoodsQueryParam;
import com.hnhcyy.goods.pojo.SpitemRelation;


/**
 * 商品关联表
 * @author sheyongjun  
 * @date 2019年2月18日
 */
public interface SpitemRelationMapper {

	@Insert("insert into spitem_relation(zspid,glspid,findex,gltype,isvisible,sjid,context,created,author,updateauthor,zspmch,glspmch)"+
			" values (#{zspid},#{glspid},#{findex},#{gltype},#{isvisible},#{sjid},#{context},#{created},#{author},#{updateauthor},#{zspmch},#{glspmch})")
	public int insert(SpitemRelation item);
	
	@Update("update spitem_relation set zspid=#{zspid},glspid=#{glspid},findex=#{findex},gltype=#{gltype},isvisible=#{isvisible},sjid=#{sjid},context=#{context},created=#{created},author=#{author},updateauthor=#{updateauthor},zspmch=#{zspmch},glspmch=#{glspmch}"+
			" where fid=#{fid} limit 1")
	public int update(SpitemRelation item);
	
	@Select("select fid,zspid,glspid,findex,gltype,isvisible,sjid,context,created,author,updated,updateauthor,zspmch,glspmch from spitem_relation where fid=#{fid}")
	public SpitemRelation select(Long fid);
	
	/**
	 * 根据商品ID查询他的所有关联商品
	 * @author sheyongjun
	 * @date 2019年2月18日
	 */
	public List<SpitemRelation> selectListBySpid(GoodsQueryParam queryParam);
	
	@Delete("delete from spitem_relation where glspid = #{glspid} and sjid = #{sjid}")
	public int deleteByGlspidAndSjid(SpitemRelation spitemRelation);
   
}
